package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Microsoft
 * Date: 2022-11-27
 * Time: 19:06
 */
class A {

}
class E extends A {

}

class C extends E {

}

public class Test {
    public static void main(String[] args) {
        A a1 = new E();
        A a2 = new C();
    }
}

//
///**
// * Created with IntelliJ IDEA.
// * Description:
// * User: Microsoft
// * Date: 2022-11-27
// * Time: 12:55
// */
//import org.omg.CORBA.PUBLIC_MEMBER;
//
///**
// * Created with IntelliJ IDEA.
// * Description:
// * User: Microsoft
// * Date: 2022-11-26
// * Time: 16:55
// */
//
//class Animal {
//    public String name;
//    public int age;
//
//    public void eat() {
//        System.out.println(name + "正在吃饭");
//    }
//}
//
//class Dog extends Animal {
//    public void wangwang() {
//        System.out.println(name + "正在汪汪叫");
//    }
//    //方法的重写
//    @Override
//    public void eat() {
//        System.out.println(name + "正在吃狗粮");
//    }
//}
//
//class Bird extends Animal {
//    public String wing;  //翅膀
//
//    //方法的重写
//    @Override
//    public void eat() {
//        System.out.println(name + "正在吃鸟粮");
//    }
//
//    public void fly() {
//        System.out.println(name + "正在飞");
//    }
//}
//public class Test2 {
//    public static void main(String[] args) {
//        Animal animal = new Dog();
///*        Dog dog = (Dog)animal;
//        dog.name = "erha";
//        dog.wangwang();*/
//        if(animal instanceof Bird) {
//            Bird bird = (Bird) animal;
//            bird.name = "小鸟";
//            bird.fly();
//        }
//    }
//}
//
//
//
////    Animal animal1 = new Dog();
////        animal1.name = "十三月";
////                function(animal1);
////
////                Animal animal2 = new Bird();
////                animal2.name = "小三";
////                function(animal2);
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Microsoft
 * Date: 2022-11-27
 * Time: 13:20
 */



//    public static void drawMap2() {
//        Rect rect = new Rect();
//        Cycle cycle = new Cycle();
//        Flower flower = new Flower();
//        String[] shapes = {"cycle","rect","cycle","rect","flower"};
//        for (String s:shapes) {
//            if(s.equals("cycle")) {
//                cycle.draw();
//            }
//            if(s.equals("rect")) {
//                rect.draw();
//            }
//            if(s.equals("flower")) {
//                flower.draw();
//            }
//        }
//    }


//    public static void drawMap() {
//        Rect rect = new Rect();
//        Cycle cycle = new Cycle();
//        Flower flower = new Flower();
//
//        Shape[] shapes = {cycle,rect,cycle,rect,flower};  //重写
//        for (Shape shape:shapes) {
//            shape.draw();
//        }
//    }

//    drawMap2();
//    public static void drawMap(Shape shape) {
//        shape.draw();
//    }
//Rect rect = new Rect();
//    drawMap(rect);
//    Cycle cycle = new Cycle();
//    drawMap(cycle);
//    drawMap(new Flower());
//class Shape {
//    public void draw() {
//        System.out.println("画图形");
//    }
//}
//class Rect extends Shape {
//    @Override
//    public void draw() {
//        System.out.println("画矩形");
//    }
//}
//class Cycle extends Shape {
//    @Override
//    public void draw() {
//        System.out.println("画圆");
//    }
//}
//class Flower extends Shape {
//    @Override
//    public void draw() {
//        System.out.println("❀");
//    }
//}
//
///**
// * Created ith IntelliJ IDEA.
// * Description:
// * User: Microsoft
// * Date: 2022-11-27
// * Time: 15:04
// */
//class B {
//    public B() {
//// do nothing
//        func();
//    }
//    public void func() {
//        System.out.println("B.func()");
//    }
//}
//class D extends B {
//    private int num = 1;
//    @Override
//    public void func() {
//        System.out.println("D.func() " + num);
//    }
//}
//public class Test4 {
//    public static void main(String[] args) {
//        D d = new D();
//    }
//}
